using Godot;
using System;
using Smr;

public partial class 组件道具选项 : PanelContainer
{
    [Signal] public delegate void 信号被点击EventHandler(组件道具 道具);
    [Export] public 组件道具 道具组件;
    [Export] public Label 标识一标签;
    [Export] public Label 标识二标签;
    [Export] public Label 标识三标签;

    private string UUID;
    private StyleBoxFlat 背景样式;
    private readonly Color 未选中背景色 = new(0, 0, 0, 0);
    private readonly Color 被选中背景色 = new(0, 0.776f, 0.651f, 0.235f);

    public bool 被选中
    {
        get { return _被选中; }
        set
        {
            _被选中 = value;
            背景样式.BgColor = _被选中 ? 被选中背景色 : 未选中背景色;
            AddThemeStyleboxOverride("panel", 背景样式);
        }
    }
    private bool _被选中 = false;

    public override void _Ready()
    {
        UUID = Guid.NewGuid().ToString();
        背景样式 = (StyleBoxFlat)GetThemeStylebox("panel").Duplicate(true);
        GuiInput += @event =>
        {
            if (@event is InputEventMouseButton mouseEvent)
            {
                if (mouseEvent.ButtonIndex == MouseButton.Left && mouseEvent.Pressed)
                {
                    EmitSignal(SignalName.信号被点击, 道具组件);
                }
            }
        };
    }

    public string 取UUID()
    {
        return UUID;
    }
}
